package top.soulblack.purchasesale.service;

import org.springframework.stereotype.Service;
import top.soulblack.purchasesale.mapper.GoodsBrandMapper;
import top.soulblack.purchasesale.model.GoodsBrand;
import top.soulblack.purchasesale.model.GoodsSize;

import javax.annotation.Resource;
import java.util.List;

/**
 * create by 小川
 */

@Service
public class GoodsBrandService{


    @Resource
    private GoodsBrandMapper goodsBrandMapper;

    public List<GoodsBrand> selectAll(){
        return goodsBrandMapper.selectAll();
    }

    public void addBrand(GoodsBrand goodsBrand){
        goodsBrandMapper.addBrand(goodsBrand);
        return;
    }

    public List<GoodsBrand> selectForName(String brandName){
        return goodsBrandMapper.selectForName(brandName);
    }

    public boolean existBrand(String name){
        int num  = goodsBrandMapper.existBrand(name);
        if (num == 1) {
            return true;
        }
        return false;
    }

    public boolean deleteBrand(int brandId) {
        int num = goodsBrandMapper.deleteById(brandId);
        if (num == 1) {
            return true;
        }
        return false;
    }

    public boolean updateBrand(GoodsBrand goodsBrand) {
        int num = goodsBrandMapper.updateByPrimaryKey(goodsBrand);
        if (num == 1) {
            return true;
        }
        return false;
    }

    public boolean selectBrand(Integer brandId){
        List<Integer> num = goodsBrandMapper.selectBrand(brandId);
        if (num  != null) {
            return true;
        }
        return false;
    }
}
